/**
 *
 */
package com.clear.login.service.impl;

import java.util.List;

import com.bis.common.entity.PermissionEntity;
import com.bis.framework.base.service.BaseService;
import com.bis.framework.entity.UserEntity;
import com.bis.framework.exception.BusinessException;
import com.bis.framework.util.common.MessagesUtil;
import com.bis.framework.util.string.CipherUtil;
import com.clear.login.dao.LoginDao;
import com.clear.login.service.LoginService;

public class LoginServiceImpl extends BaseService implements LoginService
{
	private LoginDao	loginDao	= null;

	public void setLoginDao(LoginDao loginDao)
	{
		this.loginDao = loginDao;
	}

	/**
	 * Description : 用户登录信息验证
	 * @param UserEntity loginUser
	 * @return JSONObject
	 */
	public UserEntity authenticate(UserEntity userEntity)
	{
		try
		{
			String password = userEntity.getPassword();
			password = CipherUtil.getMD5Instance().Encrypt(password);
			userEntity.setPassword(password);
			return loginDao.authenticate(userEntity);
		}
		catch (Exception e)
		{
			logger.error("异常信息:", e);
			throw new BusinessException(MessagesUtil.getMessage("system001", "default", null));
		}
	}

	/**
	 * Description : 更新用户密码
	 * @param UserEntity userEntity
	 * @return void
	 */
	public void updateUserPassword(UserEntity userEntity)
	{
		loginDao.updateUserPassword(userEntity);
	}

	public List<PermissionEntity> getUserPermission(UserEntity userEntity)
	{

		return loginDao.getUserPermission(userEntity);
	}

}
